package cn.iocoder.yudao.module.infra.controller.app.Swiper;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.controller.app.Swiper.vo.AppHomeSwiperRespVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wzy
 */
@Tag(name = "用户 App - 轮播图")
@RestController
@RequestMapping("/infra/Swiper")
@Validated
@Slf4j
public class SwiperController {
    @Resource
    private FileService fileService;

    @GetMapping("/HomeSwiper")
    @Operation(summary = "首页轮播图")
    public CommonResult<List<AppHomeSwiperRespVO>> getHomeSwiper() {
        List<FileDO> list = fileService.gerHomeSwiper();
        List<AppHomeSwiperRespVO> voList = BeanUtils.toBean(list, AppHomeSwiperRespVO.class);
        return CommonResult.success(voList);
    }
}
